<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%String path = request.getContextPath() ;%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %> 
<%@ taglib uri="/WEB-INF/tld/ui.tld" prefix="ui" %> 
<%@ taglib uri="/WEB-INF/tld/sys.tld" prefix="sys" %> 
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
 <meta name="renderer" content="webkit">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>客户列表</title>
<jsp:include page="../../import.jsp" flush="true" />
</head>

<script type="text/javascript">
	var prjId='${prjId}';
	var detailFlag = '${detailFlag}';
	var cstRlCd ='${cstRlCd}';
	var cstRlList = '${cstRlList}';
	var genderList = '${genderList}';
	var defImg = '${defImg}';
	var cstType = '${cstType}';
	var cstId = '${cstId}';
	var rlCdArr =[];
	rlCdArr = ${rlCdList};
	var genderCdList = [];
	<c:if test="${not empty genderCdList}"> genderCdList = ${genderCdList}; </c:if>
	var npgrid = null;
	var lpgrid = null; 
	var urgentPrjLinkManGrid = null;
	$(function () {
		$("#prj_cst_invest_rpt_form").ligerForm({
		    validate: true
		});
	    initForm();
	    var editFlag = true;
	    if(detailFlag=="true"){
	    	$("#addBtn").hide();
	    	$("#removeBtn").hide();
	    	$("#saveBtn").hide();
			$("#prj_cst_invest_rpt_add_btn_id").hide();
			$("#addLinkManRow").hide();
			$("#addLinkManBtn").hide();
			$("#addNpBtn").hide();
		    npgrid = liger.get("npligergrid");
		    lpgrid = liger.get("lpligergrid");
		    editFlag = false;
	    }
		initNpGrid(editFlag);
		initLpGrid(editFlag);
	    searchBtnEvent();
	    clearBtnEvent();
	    initUrgentPrjLinkManGrid();
	    if(cstType==ProjectConstant.CST_TYP_CD_LP){
			$("#lpDiv").show();
		}
	    setFormatDateValue();
	});
	//设置日期值
	function setFormatDateValue(){
		//var rptDt =$("#rptDt").val();
		var rptDt = '${prjCstInvestRpt.rptDt}';
		if(rptDt){
	    	var rptDate = DateUtils.formatDate(new Date(rptDt),DateUtils.YYYY_MM_DD);
	    	$("#rptDt").val(rptDate);//日期
	    	}
		
	}
	//清空按钮事件
	function clearBtnEvent(){
		 $("#clearBtn").click(function(event) {
		        $("#resetBtn").click();  //重置 input-text
		        var form = liger.get("searchBar");
		        form.setData({  //重置select等特殊表单
		            "cstTypCd":" ",
		            "cstRlTyp":" ",
		            "searchCstNm": " ",
		        });
		 });
	}
	
	//初始化表单
	function initForm(){
		$("#searchBar").ligerForm();
	}
	
	//查询按钮事件
	function searchBtnEvent(){
		 $("#searchBtn").click(function(event) {
	         var form = new liger.get("searchBar");
	         var data = form.getData();
	         data["cstNm"]=$("#searchCstNm").val();
	         data["cstRlTyp"] = ProjectConstant.CST_RL_SPONSOR;
	         data["prjId"] = prjId;
	         for (name in data){
	            grid.setParm(name,data[name]);
	         };
	        grid.reload();
	    });
	}
	
	//查询参数
	function getSearchParams(){
		/* var form = new liger.get("searchBar");
        var data = form.getData(); */
        var data={};
        data.cstRlTyp = ProjectConstant.CST_RL_SPONSOR;
        data.prjId=prjId;
       // data["cstNm"]=$("#searchCstNm").val();
      /*   data["cstRlTyp"] = ProjectConstant.CST_RL_SPONSOR;
        data["prjId"] = prjId; */
        return data;
	}
	var guarTypCdList = [];
	//初始化列表
	//自然人
	function initNpGrid(editFlag){
		  var data={};
	        data.cstRlTyp = ProjectConstant.CST_RL_SPONSOR;
	        data.prjId=prjId;
	        data.cstTypCd=ProjectConstant.CST_TYP_CD_NP;
		$("#npligergrid").ligerGrid({
	    	url: '<%=path%>/project/prjcstbscInfo/guarInitList.do',
	    	method : 'get',
	    	parms:data,
	        columns: [
	            { display: '客户ID', name: 'cstId', width: 50,align:'left', hide:true},
	            { display: '担保人名称', name: 'cstNm', minWidth: 140 , 
	            	render: function (rowdata, rowindex, value, column) { 
	            		var h = '';
	            		    h='<a class="sq-button-hasicon" href="javascript:detailBtn(';
	                        h+="'"+rowdata.cstId+"',";
	                        h+="'"+rowdata.cstTypCd+"'";
	                        h+=')">'+value+'</a>'
	                        return h;
	            		},
	            	enabledSort:true},
	            { display: '联系电话', name: 'cstNpBscInfoVO.mp1', width: 50,align:'left'},
	            { display: '性别', name: 'cstNpBscInfoVO.genderCdNm', width: 100,},
	            { display: '与承租人关系',
	            	  /*  editor: {
	                       type: 'select',
	                       data: rlCdArr,
	                       valueField: 'key',
	                       textField: 'value'
	                   },
	                   valueField: 'rlCd',
	                   textField: 'rlCdNm',
	                   render: function (item) {
	                       return item.rlCdNm;
	                   }, */
	            	name: 'rlCdNm', minWidth: 140},
	            { display: '身份证号码', name: 'certNo', minWidth: 140 },
				{ display: '担保属性', name: 'guaraTypCdNm', minWidth: 140 },
	            { display: '合同签署状态', name: 'conSignStsNm', minWidth: 140 },
				{ display: '签署方式', name: 'cntTypCdNm', minWidth: 140 },
	            /*{ display: '合同签署状态code', name: 'conSignSts', minWidth: 140 },*/
	             { display: '访谈记录', name: 'visRec',/* editor: {type: 'text'}, */ minWidth: 500},
	             getNpOptColumn()
	        ],
            onBeforeSubmitEdit: function (e) {//重新赋值,要不然选中后离开会把key显示在前端
                if (e.selected && e.column.columnname == "rlCdNm") {
                    e.record.rlCdId = e.value;
                    e.value = e.selected[e.column.editor.textField];
                    e.record.rlCd = e.record.rlCdId;
                }
            },
	        pageSize:100,
	        root:'rows',
	        record:'total',
	        hideLoadButton : true,
	        width: '100%',
	        heightDiff:-2,
	        checkbox:false,
	        enabledEdit: editFlag,
	        allowUnSelectRow: true,
            alternatingRow: false,
	        rownumbers:true,
	        enabledSort: false,
	        usePagerOnLessPagesize: false,
	    });
			    npgrid = liger.get("npligergrid");
			}
	
	
	//获取操作列
	function getCorpOptColumn(){
		var column = {
                display: '操作',
                isSort: false,
                width: 250,
                align:'left',
                render: function (rowdata, rowindex, value){
                	 var h="";
                	 <sys:FlowFrmAth preTaskIds="${preTaskIds}" athCd="addCreditInfo" pInstId="${pInstId}">
                		if(rowdata.id){
                		if((!detailFlag||detailFlag!="true")){
                        h+='<a class="sq-button-hasicon" href="javascript:removeBtn(';
                        h+="'"+rowdata.id+"',";
                        h+="'"+rowdata.cstTypCd+"'";
                        h+=')"><i class="sqBtnIco_7"></i>删除</a>'

                        h+='<a class="sq-button-hasicon" href="javascript:modifyCorpGuarBtn(';
                        h+="'"+rowdata.id+"',";
                        h+="'"+rowdata.cstCorpBscInfoVO.prjCstCorpTeamVO.mnm+"',";
                		if(rowdata.cstCorpBscInfoVO.prjCstCorpTeamVO.mp1){
                            h+="'"+rowdata.cstCorpBscInfoVO.prjCstCorpTeamVO.mp1+"'";
                            }else{
                          	 h+="''";
                            }
                        h+=')"><i class="sqBtnIco_4"></i>修改</a>'

                        h+='<a class="sq-button-hasicon" href="javascript:investInfo(';
                        h+="'"+rowdata.cstId+"',";
                        h+="'"+rowdata.cstTypCd+"',";
                        h+="'"+rowdata.id+"',";
                        h+="'"+rowdata.cstRlCd+"'";
                        h+=')"><i class="sqBtnIco_4"></i>资信信息</a>'
                		}
                		  h+='<a class="sq-button-hasicon" href="javascript:detailCorpGuarBtn(';
                          h+="'"+rowdata.id+"',";
                         
                          h+="'"+rowdata.cstCorpBscInfoVO.prjCstCorpTeamVO.mnm+"',";
 						if(rowdata.cstCorpBscInfoVO.prjCstCorpTeamVO.mp1){
                          h+="'"+rowdata.cstCorpBscInfoVO.prjCstCorpTeamVO.mp1+"'";
                          }else{
                        	 h+="''";
                          }
                          h+=')"><i class="sqBtnIco_2"></i>查看</a>'
                		
                		} 
                		</sys:FlowFrmAth>
                        	  return h;
                }
            }
		return column;
	}
	
	
	
	//获取操作列
	function getNpOptColumn(){
		var column = {
                display: '操作',
                isSort: false,
                width: 320,
                align:'left',
                render: function (rowdata, rowindex, value){
                	 var h="";
                	 <sys:FlowFrmAth preTaskIds="${preTaskIds}" athCd="addCreditInfo" pInstId="${pInstId}">
                		if(rowdata.id){
                		if((!detailFlag||detailFlag!="true") && (rowdata.conSignSts==0)) {
							if (StringUtils.isEmpty(rowdata.conSignSts) || rowdata.conSignSts == 0) {
								h += '<a class="sq-button-hasicon" href="javascript:removeBtn(';
								h += "'" + rowdata.id + "',";
								h += "'" + rowdata.cstTypCd + "',";
								h += "'" + rowdata.isPushCon + "',";
								h += "'" + rowdata.guaraTypCd + "'";
								h += ')"><i class="sqBtnIco_7"></i>删除</a>'
							}
							h += '<a class="sq-button-hasicon" href="javascript:modifyNpGuarBtn(';
							h += "'" + rowdata.id + "',";
							h += "'" + rowdata.cstNpBscInfoVO.mp1 + "',";
							h += "'" + rowdata.isPushCon + "',";
							h += "'" + rowdata.cstNpBscInfoVO.genderCdNm + "'";
							h += ')"><i class="sqBtnIco_4"></i>修改</a>'
						}
						if((!detailFlag||detailFlag!="true")){
							h+='<a class="sq-button-hasicon" href="javascript:investInfo(';
							h+="'"+rowdata.cstId+"',";
							h+="'"+rowdata.cstTypCd+"',";
							h+="'"+rowdata.id+"',";
							h+="'"+rowdata.cstRlCd+"'";
							h+=')"><i class="sqBtnIco_4"></i>资信信息</a>'
                		}
                		 h+='<a class="sq-button-hasicon" href="javascript:detailNpGuarBtn(';
                         h+="'"+rowdata.id+"',";
                         h+="'"+rowdata.cstNpBscInfoVO.mp1+"',";
                         h+="'"+rowdata.cstNpBscInfoVO.genderCdNm+"'";
                         h+=')"><i class="sqBtnIco_2"></i>查看</a>'
                		
                		} 
                		if ((!detailFlag||detailFlag!="true") && rowdata.cntTypCd==1
								&& (StringUtils.isEmpty(rowdata.conSignSts) || rowdata.conSignSts==0) && rowdata.isPushCon==0) {
                			h+='<a class="sq-button-hasicon" href="javascript:pushCon(';
                			h+="'"+rowdata.id+"',";
							h+="'"+rowdata.guaraTypCd+"'";
							h+=')"><i class="sqBtnIco_3"></i>推送合同</a>'
						}
                	 </sys:FlowFrmAth>
                        	  return h;
                }
            }
		return column;
	}
	//法人
	function initLpGrid(editFlag){
		 var data={};
	        data.cstRlTyp = ProjectConstant.CST_RL_SPONSOR;
	        data.prjId=prjId;
	        data.cstTypCd=ProjectConstant.CST_TYP_CD_LP;
		$("#lpligergrid").ligerGrid({
	    	url: '<%=path%>/project/prjcstbscInfo/guarInitList.do',
	    	method : 'get',
	    	parms:data,
	        columns: [
	            { display: '客户ID', name: 'cstId', width: 50,align:'left', hide:true},
	            { display: '公司名称', name: 'cstNm', minWidth: 140 , 
	            	render: function (rowdata, rowindex, value, column) { 
	            		var h = '';
	            		    h='<a class="sq-button-hasicon" href="javascript:detailBtn(';
	                        h+="'"+rowdata.cstId+"',";
	                        h+="'"+rowdata.cstTypCd+"'";
	                        h+=')">'+value+'</a>'
	                        return h;
	            		},
	            	enabledSort:true},
	            { display: '法人姓名', name: 'cstCorpBscInfoVO.prjCstCorpTeamVO.mnm', width: 100},
	            { display: '联系电话', name: 'cstCorpBscInfoVO.prjCstCorpTeamVO.mp1', width: 100},
	             { display: '访谈记录', name: 'visRec', minWidth: 500},
	             getCorpOptColumn()
	        ],
            onBeforeSubmitEdit: function (e) {//重新赋值,要不然选中后离开会把key显示在前端
                if (e.selected && e.column.columnname == "rlCdNm") {
                    e.record.rlCdId = e.value;
                    e.value = e.selected[e.column.editor.textField];
                    e.record.rlCd = e.record.rlCdId;
                }
            },
	        pageSize:100,
	        root:'rows',
	        record:'total',
	        hideLoadButton : true,
	        width: '100%',
	        heightDiff:-2,
	        checkbox:false,
	        enabledEdit: editFlag,
	        allowUnSelectRow: true,
            alternatingRow: false,
	        rownumbers:true,
	        enabledSort: false,
	        usePagerOnLessPagesize: false,
	    });
			    lpgrid = liger.get("lpligergrid");
			}
	

	
	function detailBtn(id,cstTypCd){
		if(cstTypCd==CustomerConstant.CST_TYPE_NP_CD){
			Add_navTab('tab_cst_detail'+id,'担保人详情','<%=path%>/customer/external/toCstDetailForPrjGuarCreditPage.do?id='+id);
		}
		if(cstTypCd==CustomerConstant.CST_TYPE_CORP_CD){
			Add_navTab('tab_cst_detail'+id,'担保人详情','<%=path%>/customer/external/toCstDetailForPrjGuarCreditPage.do?id='+id);
		}
	}
	function investInfo(cstId,cstTypCd,id,cstRlCd){
		     Add_navTab('tab_guar_invest_modify_page'+cstId,'担保人资信信息','<%=path%>/project/prjbscinfo/toGuarPhotosListPage.do?cstId='+cstId+'&&cstTypCd='+cstTypCd+'&&prjId='+prjId+'&&detailFlag='+detailFlag+'&&cstRlCd='+cstRlCd+'&&prjCstId='+id);
	}
	
	function modifyBtn(id,cstTypCd){
		if(cstTypCd==CustomerConstant.CST_TYPE_NP_CD){
			Add_navTab('tab_cst_modify_page'+id,'修改担保人信息','<%=path%>/customer/external/toCstModifyForPrjGuarCreditPage.do?id='+id);
		}
		if(cstTypCd==CustomerConstant.CST_TYPE_CORP_CD){
			Add_navTab('tab_cst_modify_page'+id,'修改担保人信息','<%=path%>/customer/external/toCstModifyForPrjGuarCreditPage.do?id='+id);
		}
		
	}
	//格式化时间
	function renderDate(rowdata, index, value){
		var dateStr = "";
		if(null != value&&value!=''){
			var date = new Date(value);
			dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DD);
		}
		return dateStr;
	}
	
	
	
	
	
	function checkAmt(amt){
		 var num = new Number(amt);
			var sAmt = parseFloat(amt).toString();
			return sAmt; 
	}
	//添加
	function addBtn(){
		var cstRlFlag = ProjectConstant.CST_RL_SPONSOR;//担保人
  		var win = $.ligerDialog.SQopen({ title: '添加担保人',height: 600,width: 850, url: '<%=path%>/project/prjbscinfo/toChoosePrjCstPage.do?cstRlFlag='+cstRlFlag, isResize: true });
	}
	
	//添加自然担保人
	function addNpBtn(){
		var cstRlFlag = ProjectConstant.CST_RL_SPONSOR;//担保人
		//var cstTypCd = ProjectConstant.CST_TYP_CD_NP;
		var url = '<%=path%>/project/prjbscinfo/toChoosePrjCstPage.do?cstRlFlag='+cstRlFlag;
  		var win = $.ligerDialog.SQopen({ title: '添加担保人',height: 600,width: 850, url: url, isResize: true });
	}
	//添加法人担保人
	function addLpBtn(){
		var cstTypCd = ProjectConstant.CST_TYP_CD_LP;
		var cstRlFlag = ProjectConstant.CST_RL_SPONSOR;//担保人
		var url = '<%=path%>/project/prjbscinfo/toChoosePrjCstPage.do?cstRlFlag='+cstRlFlag+'&&cstTypCd='+cstTypCd;
  		var win = $.ligerDialog.SQopen({ title: '添加担保人',height: 600,width: 850, url:url, isResize: true });
	}
	function clearBtn(){
		var form = new liger.get("searchBar");
		form.clear();
	}
	
	function iframeResize () {
	    if (parent.mainApp) {
	        parent.mainApp.parentTab.onResize();
	    };
	}
	//推送担保合同
	function pushCon(id,guaraTypCd){
		if (!id){
			return;
		}
		var params = {};
		params.id = id;
		params.guaraTypCd = guaraTypCd;
		$.ajax({
			type: 'post',
			dataType:'json',
			data:params,
			url: '<%=path%>/project/prjcstbscInfo/pushCon.do',
			success:function(msg){
				 if(msg.success == 1){
					 if(cstTypCd=ProjectConstant.CST_TYP_CD_NP){
						 npgrid.reload();
						};
				 }else{
					 top.$.ligerDialog.SQalert({content: msg.info,SQ_type: "error"});
				 }
			}
		});
	}
	//删除所选项目客户信息
	function removeBtn(id,cstTypCd,isPushCon,guaraTypCd){
		$.ligerDialog.confirm(LogUtils.LOG_CMM_DELETE_CONFIRM, function (flag) {
		if(!id || id=="undefined"){
		    if(cstTypCd=ProjectConstant.CST_TYP_CD_NP){
		    	var manager = $("#npligergrid").ligerGetGridManager();
				 manager.deleteSelectedRow();
				 return;
		    };
		    if(cstTypCd=ProjectConstant.CST_TYP_CD_LP){
		    	var manager = $("#lpligergrid").ligerGetGridManager();
				 manager.deleteSelectedRow();
				 return;
		    }
		}
		if(flag == false)return;
		var params = {};
		params.guaraTypCd = guaraTypCd;
		params.prjId = prjId;
		params.isPushCon = isPushCon;
		params.id = id;
			$.ajax({
				type: 'post',
				dataType:'json',
				data:params,
				url: '<%=path%>/project/prjcstbscInfo/removeCstAndDelCont.do',
				success:function(msg){
					 if(msg.success == 1){
						 if(cstTypCd=ProjectConstant.CST_TYP_CD_NP){
							 npgrid.reload();
						    };
						    if(cstTypCd=ProjectConstant.CST_TYP_CD_LP){
						    lpgrid.reload();
						    };
						
					 }else{
						 top.$.ligerDialog.SQalert({content: msg.info,SQ_type: "error"});
					 }
				}
			});
		});
		
	}
	//保存所选项目担保人信息
	function addSelect(guarList,cstTypCd){
		  var params = {};
		  params.prjId = prjId;
		  params.cstRlTyp =ProjectConstant.CST_RL_SPONSOR;   
		  params.prjCstBscInfo = JSON.stringify(guarList);
		     var wait_dialog;
			$.ajax({
				type: 'post',
				dataType:'json',
				data:params,
				url: '<%=path%>/project/prjcstbscInfo/addSelectPrjCstBscInfo.do',
				beforeSend: function(){
			          wait_dialog=$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING ,SQ_type: "waitting" });
			     },
				success:function(msg){
					 wait_dialog.close();
					 if(msg.success == 1){
						 top.$.ligerDialog.SQalert({content: msg.info,SQ_type: "success"});
						 if(cstTypCd=ProjectConstant.CST_TYP_CD_NP){
							 npgrid.reload();
						    };
						    if(cstTypCd=ProjectConstant.CST_TYP_CD_LP){
						    lpgrid.reload();
						    };
					 }else{
						 top.$.ligerDialog.SQalert({content: msg.info,SQ_type: "error"});
					 }
				}
			});
	}
	
	
	//保存所选项目担保人信息
	function addNpSelect(guarList,cstTypCd){
		  var params = {};
		  params.prjId = prjId;
		  params.cstRlTyp =ProjectConstant.CST_RL_SPONSOR;   
		  params.prjCstBscInfo = JSON.stringify(guarList);
		     var wait_dialog;
			$.ajax({
				type: 'post',
				dataType:'json',
				data:params,
				url: '<%=path%>/project/prjcstbscInfo/addSelectPrjCstBscInfo.do',
				beforeSend: function(){
			          wait_dialog=$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING ,SQ_type: "waitting" });
			     },
				success:function(msg){
					 wait_dialog.close();
					 if(msg.success == 1){
						 top.$.ligerDialog.SQalert({content: msg.info,SQ_type: "success"});
							 npgrid.reload();
						    
					 }else{
						 top.$.ligerDialog.SQalert({content: msg.info,SQ_type: "error"});
					 }
				}
			});
	}
	
	//保存所选项目担保人信息
	function addLpSelect(guarList,cstTypCd){
		  var params = {};
		  params.prjId = prjId;
		  params.cstRlTyp =ProjectConstant.CST_RL_SPONSOR;   
		  params.prjCstBscInfo = JSON.stringify(guarList);
		     var wait_dialog;
			$.ajax({
				type: 'post',
				dataType:'json',
				data:params,
				url: '<%=path%>/project/prjcstbscInfo/addSelectPrjCstBscInfo.do',
				beforeSend: function(){
			          wait_dialog=$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING ,SQ_type: "waitting" });
			     },
				success:function(msg){
					 wait_dialog.close();
					 if(msg.success == 1){
						 top.$.ligerDialog.SQalert({content: msg.info,SQ_type: "success"});
						    lpgrid.reload();
					 }else{
						 top.$.ligerDialog.SQalert({content: msg.info,SQ_type: "error"});
					 }
				}
			});
	}
	
	
	
	function modifyOthInfo(){
		  var params = {};
		  params.prjId = prjId;
		  params.cstRlTyp =ProjectConstant.CST_RL_SPONSOR;   
		  params.prjCstBscInfo = JSON.stringify(grid.getData());
		     var wait_dialog;
			$.ajax({
				type: 'post',
				dataType:'json',
				data:params,
				url: '<%=path%>/project/prjcstbscInfo/modifySelectPrjCstBscInfo.do',
				beforeSend: function(){
			          wait_dialog=$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING ,SQ_type: "waitting" });
			     },
				success:function(msg){
					 wait_dialog.close();
					 if(msg.success == 1){
						 top.$.ligerDialog.SQalert({content: msg.info,SQ_type: "success"});
						 grid.reload();
					 }else{
						 top.$.ligerDialog.SQalert({content: msg.info,SQ_type: "error"});
					 }
				}
			});
	}
	
	
	
	function saveLpInfo(){
		  var params = {};
		  params.prjId = prjId;
		  params.cstRlTyp =ProjectConstant.CST_RL_SPONSOR;   
		  params.prjCstBscInfo = JSON.stringify(lpgrid.getData());
		     var wait_dialog;
			$.ajax({
				type: 'post',
				dataType:'json',
				data:params,
				url: '<%=path%>/project/prjcstbscInfo/modifySelectPrjCstBscInfo.do',
				beforeSend: function(){
			          wait_dialog=$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING ,SQ_type: "waitting" });
			     },
				success:function(msg){
					 wait_dialog.close();
					 if(msg.success == 1){
						 top.$.ligerDialog.SQalert({content: msg.info,SQ_type: "success"});
						 lpgrid.reload();
					 }else{
						 top.$.ligerDialog.SQalert({content: msg.info,SQ_type: "error"});
					 }
				}
			});
	}
	
	
	function saveNpInfo(){
		  var params = {};
		  params.prjId = prjId;
		  params.cstRlTyp =ProjectConstant.CST_RL_SPONSOR;   
		  params.prjCstBscInfo = JSON.stringify(npgrid.getData());
		     var wait_dialog;
			$.ajax({
				type: 'post',
				dataType:'json',
				data:params,
				url: '<%=path%>/project/prjcstbscInfo/modifySelectPrjCstBscInfo.do',
				beforeSend: function(){
			          wait_dialog=$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING ,SQ_type: "waitting" });
			     },
				success:function(msg){
					 wait_dialog.close();
					 if(msg.success == 1){
						 top.$.ligerDialog.SQalert({content: msg.info,SQ_type: "success"});
						 npgrid.reload();
					 }else{
						 top.$.ligerDialog.SQalert({content: msg.info,SQ_type: "error"});
					 }
				}
			});
	}
	
	
	
	//紧急联系人初始化列表
	function initUrgentPrjLinkManGrid(){
		var params = {};
		params.prjId = prjId;
		$("#prjLinkManGrid").ligerGrid({
			url: '<%=path%>/project/prjlinkman/initList.do',
	    	method : 'get',
	    	parms:params,
	        columns: [
	             { display: '联系人姓名', name: 'lnkNm', minWidth: 140 ,editor: {type: 'text'},
	            	  /*  	render: function (rowdata, rowindex, value, column) { 
		            		var h = '';
		            		    h='<a class="sq-button-hasicon" href="javascript:detailLinkManBtn(';
		                        h+="'"+rowdata.cstId+"',";
		                        h+="'"+rowdata.cstTypCd+"'";
		                        h+=')">'+value+'</a>'
		                        return h;
		            		}, */
	  	            	enabledSort:true},
	            { display: '联系电话', name: 'mp', minWidth: 100 ,editor: {type: 'text'},enabledSort:true},
	            { display: '性别', name: 'genderCdNm', minWidth: 140 ,
	         	   editor: {
                       type: 'select',
                       data: genderCdList,
                       valueField: 'key',
                       textField: 'value'
                   },
                   valueField: 'genderCd',
                   textField: 'genderCdNm',
                   render: function (item) {
                       return item.genderCdNm;
                   },
	            	enabledSort:true},
	            { display: '与承租人关系',
	            	   editor: {
	                       type: 'select',
	                       data: rlCdArr,
	                       valueField: 'key',
	                       textField: 'value'
	                   },
	                   valueField: 'rlCd',
	                   textField: 'rlCdNm',
	                   render: function (item) {
	                       return item.rlCdNm;
	                   },
	            	name: 'rlCdNm', minWidth: 140},
	            { display: '访谈记录', name: 'visRec',editor: {type: 'text'}, minWidth: 500},
	            {
	                display: '操作',
	                isSort: false,
	                width: 100,
	                render: function (rowdata, rowindex, value){
						<c:if test="${detailFlag != 'true'}">
	                	<sys:FlowFrmAth preTaskIds="${preTaskIds}" athCd="addCreditInfo" pInstId="${pInstId}">
		                    var h='<a class="sq-button-hasicon" href="javascript:removeUrgentPrjLinkMan(';
		                  		  h+="'"+rowdata.id+"'";
		                          h+=')"><i class="sqBtnIco_3"></i>删除</a>'
		                    return h;
	                	</sys:FlowFrmAth>
						</c:if>
	                }
	            }
	        ],
	        onBeforeSubmitEdit: function (e) {//重新赋值,要不然选中后离开会把key显示在前端
                if (e.selected && e.column.columnname == "rlCdNm") {
                    e.record.rlCdId = e.value;
                    e.value = e.selected[e.column.editor.textField];
                    e.record.rlCd = e.record.rlCdId;
                }
                if (e.selected && e.column.columnname == "genderCdNm") {
                    e.record.genderCdId = e.value;
                    e.value = e.selected[e.column.editor.textField];
                    e.record.genderCd = e.record.genderCdId;
                }
            },
	        pageSize:100,
	        root:'rows',
	        record:'total',
	        hideLoadButton : true,
	        width: '100%',
	        heightDiff:-2,
	        checkbox:true,
	        enabledEdit: true,
	        allowUnSelectRow: true,
            alternatingRow: false,
	        rownumbers:true,
	        usePagerOnLessPagesize: false,
	    });
		urgentPrjLinkManGrid = liger.get("prjLinkManGrid");
	}
	
	
	
	//删除所选项目客户信息
	function removeUrgentPrjLinkMan(id){
		var _ids = [];
		$.ligerDialog.confirm(LogUtils.LOG_CMM_DELETE_CONFIRM, function (flag) {
		if(id&&id!="undefined"){
			_ids.push(id);
		}else{
			var manager = $("#prjLinkManGrid").ligerGetGridManager();
			 manager.deleteSelectedRow();
			 return;
		}
			if(flag == false)return;
			$.ajax({
				type: 'post',
				dataType:'json',
				data:{ids:JSON.stringify(_ids)},
				url: '<%=path%>/project/prjlinkman/removeByIds.do',
				success:function(msg){
					 if(msg.success == 1){
						 urgentPrjLinkManGrid.reload();
					 }else{
						 top.$.ligerDialog.SQalert({content: msg.info,SQ_type: "error"});
					 }
				}
			});
		});
		
	}
	
	function addLinkManRow(){
			//添加担保人信息
 			var manager = $("#prjLinkManGrid").ligerGetGridManager();
            manager.addRow({
            lnkNm:'',
			mp:'',
			genderCd:'',
			genderCdNm:'',
			rlCd:'',
			rlCdNm:'',
			visRec:'',
            });
	}
	//保存所选项目联系人信息
	function addLinkMan(){
		  var prjlinkManList = urgentPrjLinkManGrid.getData();
		var params = {};
		params.prjId = prjId;
		params.prjlinkManList = JSON.stringify(prjlinkManList);
	     var wait_dialog;
			$.ajax({
				type: 'post',
				dataType:'json',
				data:params,
				url: '<%=path%>/project/prjlinkman/add.do',
				beforeSend: function(){
					wait_dialog=$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING ,SQ_type: "waitting" });
                },
				success:function(msg){
					 wait_dialog.close();
					 if(msg.success == 1){
						 top.$.ligerDialog.SQalert({content: msg.info,SQ_type: "success"});
						 urgentPrjLinkManGrid.reload();
					 }else{
						 top.$.ligerDialog.SQalert({content: msg.info,SQ_type: "error"});
					 }
				}
			});
	}
	
	function uploadFile(imgObj,sysCd,orgCd,cfgCd,cfgDtlCd){
		var obj = $(imgObj).parent().parent().find("img")
		var  url = '<%=path%>/project/prjbscinfo/addInvestImgPage.do?sysCd='+sysCd+'&&orgCd='+orgCd+'&&cfgCd='+cfgCd+'&&cfgDtlCd='+cfgDtlCd+'&&prjId='+prjId;
		$.ligerDialog.open({
            height:300,
            width: 600,
            title : '上传图片',
            url: url, 
            showMax: false,
            showToggle: true,
            showMin: false,
            isResize: true,
            slide: false,
            data: {
            	imgObj: obj
            },
        });

		
       // $.ligerDialog.open({ height: 300,width: 500, url: '<%=path%>/project/prjbscinfo/addInvestImgPage.do?sysCd='+sysCd+'&&orgCd='+orgCd+'&&cfgCd='+cfgCd+'&&cfgDtlCd='+cfgDtlCd+'&&prjId='+prjId, isResize: true});
	}
	function removeFileRec(imgObj,id){
		var obj = $(imgObj).parent().parent().find("img");
		var fileId = obj.attr("fileId");
		$.ligerDialog.confirm('确定删除吗?', function (flag) {
			if(flag == false)return;
			var wait_dialog;
			$.ajax({
				type: 'post',
				dataType:'json',
				data:{id:id},
				url: '<%=path%>/system/sysulfilesrec/removeById.do',
				beforeSend: function(){
			          wait_dialog=$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING ,SQ_type: "waitting" });
			     },
				success:function(msg){
					wait_dialog.close();
					 if(msg.success == 1){
							var obj = $(imgObj).parent().parent().find("img");
						// var imgPath = "http://10.10.36.18:80/attachments/default/placeholder.png";
						 var imgPath=defImg;
 						  obj.attr("src",imgPath);
						 top.$.ligerDialog.SQalert({content:msg.info, SQ_type: "success"});
					 }else{
						 top.$.ligerDialog.SQalert({content:msg.info, SQ_type: "error"});
					 }
				}
			});
		});
	}
	function showImg(e){
/* 		 e.preventDefault();
      var href = $(e.target).attr('href');
      if(!href){
    	  return;
      }
      if(SQ.regs.img.test(href)){
          SQ.imgPreview(href);
      } */
		 e.preventDefault();
		   var href = $(e.target).attr('src');
		      if(!href){
		    	  return;
		      }
		      if(SQ.regs.img.test(href)){
			       var imgSrc = $(e.target).attr('src'),
			           imgTit = $(e.target).attr('title');
			       window.__ImgSrc = imgSrc;
			       window.__ImgTit = imgTit;
			       window.open('<%=path%>/project/prjbscinfo/imgWinOpen.do', '', 'location=yes, width=800, height=600');
		      }
	}
	
	function save(){
        var ligerForm = liger.get("prj_cst_invest_rpt_form");
        if (!ligerForm.valid()) {
            top.$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_MUST_FIX_ITEM_INFO,SQ_type: "warning"});
            return false; //验证不通过，不执行以下代码
        }
        var data = ligerForm.getData();
        data["rptDt"] = $("#rptDt").val();
        var url = '<%=path%>/project/prjcstinvestrpt/add.do';
        var rptId = $("#rptId").val();
        data["id"]= rptId;
        data["prjId"]= prjId;
        data["cstId"]= cstId;
        data["cstRlCd"] = cstRlCd;
        var wait_dialog;
        $.ajax({
    		type: 'post',
    		dataType:'json',
    		data:data,
    		url: url,
    		beforeSend: function(){
		          wait_dialog=$.ligerDialog.SQalert({content: LogUtils.LOG_CMM_DATA_LOADING ,SQ_type: "waitting" });
		     },
    		success:function(msg){
    			 wait_dialog.close();
    			 if(msg.success == 1){
    				 $("#rptId").val(msg.data);
    				 top.$.ligerDialog.SQalert({content: msg.info,SQ_type: "success"});
    			 }else{
    				 top.$.ligerDialog.SQalert({content: msg.info,SQ_type: "error"});
    			 }
    		}
    	});
	}
	
	function modifyNpGuarBtn(id,mp1,isPushCon,genderCdNm){
		var  url = '<%=path%>/project/prjcstbscInfo/modifyNpGuarPage.do?id='+id+'&&mp1='+mp1+'&&genderCdNm='+genderCdNm+'&&prjId='+prjId +'&&isPushCon='+isPushCon;
		$.ligerDialog.SQopen({
            height:300,
            width: 600,
            title : '修改担保人信息',
            url: url, 
            showMax: false,
            showToggle: true,
            showMin: false,
            isResize: true,
            slide: false,
        });
	}
	
	function detailNpGuarBtn(id,mp1,genderCdNm){
		var  url = '<%=path%>/project/prjcstbscInfo/detailNpGuarPage.do?id='+id+'&&mp1='+mp1+'&&genderCdNm='+genderCdNm;
		$.ligerDialog.SQopen({
            height:300,
            width: 600,
            title : '查看担保人信息',
            url: url, 
            showMax: false,
            showToggle: true,
            showMin: false,
            isResize: true,
            slide: false,
        });
	}
	
	function modifyCorpGuarBtn(id,mnm,mp1){
		var  url = '<%=path%>/project/prjcstbscInfo/modifyCorpGuarPage.do?id='+id+'&&mnm='+mnm+'&&mp1='+mp1;
		$.ligerDialog.SQopen({
            height:300,
            width: 600,
            title : '修改担保人信息',
            url: url, 
            showMax: false,
            showToggle: true,
            showMin: false,
            isResize: true,
            slide: false,
        });
	}
	
	function detailCorpGuarBtn(id,mnm,mp1){
		var  url = '<%=path%>/project/prjcstbscInfo/detailCorpGuarPage.do?id='+id+'&&mnm='+mnm+'&&mp1='+mp1;
		$.ligerDialog.SQopen({
            height:300,
            width: 600,
            title : '查看担保人信息',
            url: url, 
            showMax: false,
            showToggle: true,
            showMin: false,
            isResize: true,
            slide: false,
        });
	}
	
	
</script>

<body class="iframeBody">
<div class="Wrapper">
 <div id="pageInTab" class="pageInTab">
  <div class="sqCaption-normal">
	            <div class="tit">
	          担保人信息
	            </div>
     </div>
  <!--        <div class="clearFix"></div>
         <div class="btnsBox">
            <span id="addBtn" onclick="addBtn();" class="sq-button sq-button-round">新增</span>
             <span id="modifyOthInfoBtn" onclick="modifyOthInfo();" class="sq-button sq-button-round">保存</span>
	 </div> -->
	   <div style="display: none">
             <input type="hidden"  id="cstId" name="cstId"  class="ui-textbox" value="${cstId}">
            <input type="hidden"  id="prjId" name="prjId"  class="ui-textbox" value="${prjId}">
            <input type="hidden"  id="cstStsCdNm" name="cstStsCdNm"  class="ui-textbox" value="">
            <input type="hidden"  id="cstLvlCdNm" name="cstLvlCdNm"  class="ui-textbox" value="">
            <input type="hidden"  id="cstNm" name="cstNm"  class="ui-textbox" value="">
            <input type="hidden"  id="cstTypCd" name="cstTypCd"  class="ui-textbox" value="">
            <input type="hidden"  id="cstTypCdNm" name="cstTypCdNm"  class="ui-textbox" value="">
            <input type="hidden"  id="certNo" name="certNo"  class="ui-textbox" value="">
            <input type="hidden"  id="crtTm" name="crtTm"  class="ui-textbox" value="">
             <input type="hidden"  id="guarTypCdNm" name="guarTypCdNm"  class="ui-textbox" value="">
              <input type="hidden"  id="guarTypCd" name="guarTypCd"  class="ui-textbox" value="">
            <input type="hidden"  id="guarAmt" name="guarAmt"  class="ui-textbox" value="">
             <input type="hidden"  id="mp1" name="mp1"  class="ui-textbox" value="">
              <input type="hidden"  id="genderCdNm" name="genderCdNm"  class="ui-textbox" value="">
               <input type="hidden"  id="genderCd" name="genderCd"  class="ui-textbox" value="">
               
	        <!-- 流程使用开始 -->
	        <input name="preTaskIdsNm" id="preTaskIds" type="text" style="display: none;" value="${preTaskIds}"/>
	        <input name="pInstIdNm" id="pInstId" type="text" style="display: none;" value="${pInstId}"/>
	        <!-- 流程使用结束-->
        </div>
     <div class="sqPanel">
            <div class="sqPanel_head inL">
                <span>自然人</span>
            <div class="clearFix"></div>
	         <div class="btnsBox posL">
	         <sys:FlowFrmAth preTaskIds="${preTaskIds}" athCd="addCreditInfo" pInstId="${pInstId}">
	            <span id="addNpBtn" onclick="addNpBtn();" class="sq-button sq-button-round">新增</span>
			 </sys:FlowFrmAth>
	       <!--       <span id="saveNpInfoBtn" onclick="saveNpInfo();" class="sq-button sq-button-round">保存</span> -->
		     </div>
            </div>
            <div class="sqPanel_body">
                <div id="npligergrid" class="sq-grid"></div>
            </div>
   </div>
   
   
     <div class="sqPanel">
            <div class="sqPanel_head inL">
                <span>法人</span>
                  <div class="clearFix"></div>
  <!--        <div class="btnsBox posL">
            <span id="addLpBtn" onclick="addLpBtn();" class="sq-button sq-button-round">新增</span>
             <span id="savelpInfo" onclick="saveLpInfo();" class="sq-button sq-button-round">保存</span>
	     </div> -->
        <div style="display: none">
             <input type="hidden"  id="cstId" name="cstId"  class="ui-textbox" value="${cstId}">
            <input type="hidden"  id="prjId" name="prjId"  class="ui-textbox" value="${prjId}">
            <input type="hidden"  id="cstStsCdNm" name="cstStsCdNm"  class="ui-textbox" value="">
            <input type="hidden"  id="cstLvlCdNm" name="cstLvlCdNm"  class="ui-textbox" value="">
            <input type="hidden"  id="cstNm" name="cstNm"  class="ui-textbox" value="">
            <input type="hidden"  id="cstTypCd" name="cstTypCd"  class="ui-textbox" value="">
            <input type="hidden"  id="cstTypCdNm" name="cstTypCdNm"  class="ui-textbox" value="">
            <input type="hidden"  id="certNo" name="certNo"  class="ui-textbox" value="">
            <input type="hidden"  id="crtTm" name="crtTm"  class="ui-textbox" value="">
             <input type="hidden"  id="guarTypCdNm" name="guarTypCdNm"  class="ui-textbox" value="">
              <input type="hidden"  id="guarTypCd" name="guarTypCd"  class="ui-textbox" value="">
            <input type="hidden"  id="guarAmt" name="guarAmt"  class="ui-textbox" value="">
             <input type="hidden"  id="mp1" name="mp1"  class="ui-textbox" value="">
              <input type="hidden"  id="genderCdNm" name="genderCdNm"  class="ui-textbox" value="">
               <input type="hidden"  id="genderCd" name="genderCd"  class="ui-textbox" value="">
        </div>
            </div>
            <div class="sqPanel_body">
                <div id="lpligergrid" class="sq-grid"></div>
            </div>
   </div>
   
   				<div class="sqPanel">
		            <div class="sqPanel_head">
		                <span>紧急联系人信息</span>
		               <div class="clearFix"></div>
			            <div class="btnsBox posL">
			            <sys:FlowFrmAth preTaskIds="${preTaskIds}" athCd="addCreditInfo" pInstId="${pInstId}">
			                <span id="addLinkManRow"  class="sq-button sq-button-round" onclick="addLinkManRow();" class="sq-button sq-button-round">新增</span>
			                <span id="addLinkManBtn" class="sq-button sq-button-round" onclick="addLinkMan();" class="sq-button sq-button-round">保存</span>
						</sys:FlowFrmAth>
			  		   </div>
		            </div>
		            <div class="sqPanel_body">
		                <div id="prjLinkManGrid" class="sq-grid"></div>
		            </div>
  			   </div> 
  			   
  			 <div class="sqPanel">
		            <div class="sqPanel_head inL">
		                <span>承租人考察</span>
		            </div>
		            <table class="table_full tbl_1">
			            <tbody>
						   <tr>  
							    <c:forEach items="${dtlList}" var="cstFile" varStatus="status">  
							        <c:if test="${status.index%4==0}">  
							            </tr>  
							            <tr>  
							        </c:if>  
								 <td>
									  <h5>${cstFile.datNm}</h5>
									  <div class="imgBox">
									  <c:if test="${ empty cstFile.filePath}">
									  <img src="${defImg}"  onclick="showImg(event);" fileId="">
									  </c:if>
									<c:if test="${ not empty cstFile.filePath}">
									  <img id="imgPath" src="${cstFile.filePath}" onclick="showImg(event);" href="${cstFile.filePath}" fileId="">
									</c:if>
									  <%-- <img src="${cstFile.fileRec.filePath}"> --%>
									  </div>
									    <div class="btns">
											<c:if test="${detailFlag != 'true'}">
									    	<sys:FlowFrmAth preTaskIds="${preTaskIds}" athCd="addCreditInfo" pInstId="${pInstId}">
						                    	<span class="sq-button sq-button-round co_normal"  sysCd="${cstFile.sysCd}" orgCd="${cstFile.orgCd}" cfgCd="${cstFile.cfgCd}" cfgDtlCd="${cstFile.cfgDtlCd}" <%-- cfgDtId="${cstFile.cfgDtId}"  --%> onclick="uploadFile(this,'${cstFile.sysCd}','${cstFile.orgCd}','${cstFile.cfgCd}','${cstFile.cfgDtlCd}')">上传</span>
									    	</sys:FlowFrmAth>
											</c:if>
						                    <span class="sq-button sq-button-round co_normal" <%--  onclick="downLoad('${cstFile.fileRec.filePath}');" --%>>
						                     <a target="_blank"  href="<%=path%>/system/sysulfilesrec/downLoad.do?fileName=${cstFile.fileNm}&filePath=${cstFile.filePath}">下载</a>
						                    </span>
											<c:if test="${detailFlag != 'true'}">
									    	<sys:FlowFrmAth preTaskIds="${preTaskIds}" athCd="addCreditInfo" pInstId="${pInstId}">
							                    <span class="sq-button sq-button-round co_normal" onclick="removeFileRec(this,'${cstFile.id}')">删除</span>
									    	</sys:FlowFrmAth>
											</c:if>
                						</div>
							      </td>  
							    </c:forEach>  
							</tr> 
			            </tbody>
		            </table>
		         
  			 </div>
  			 <div style="display: none" id="lpDiv">
  			 <div class="sqPanel">
  			   <form id="prj_cst_invest_rpt_form">
                        <div class="fieldset1 tabel_col clearFix">
		                      <div class="fieldBox col_100">
				                    <div class="label">意见：</div>
				                    <div class="field">
				                        <input name="sugg"  id="sugg" type="text" class="ui-textbox" value="${prjCstInvestRpt.sugg }" >
				                    </div>
		               		 </div>
                                 <div class="fieldBox col_100">
                                <div class="label">承诺：</div>
                                <div class="field">
  									 <span>承诺：本人承诺承租人信息已现场核实，并对承租人做了尽职调查。<br/>并现场监督了客户在租赁合同及相关法律文件上的签字用印，对其真实性进行了核实。<br/>向公司提供的承租人相关权证资料包括但不限于车辆销售发票、车辆保单、车辆登记证书、车辆钥匙及法律文件等资料和手续真实有效。<br/>若由于上述法律文件及资料真实性原因导致公司权益受到侵害，我个人愿意承担一切责任。</span>
                                   </div>
                            </div>
                            <%--     <div class="fieldBox col_50">
                                <div class="label">报告类型：</div>
                                <div class="field">
                                 <select name="cstRptTypCd"  id="cstRptTypCd"   >
	                                <c:forEach items="${keyList}" var="opt">
	                                 <option value="${opt.key}"
	                                 <c:if test="${opt.key==prjCstInvestRpt.cstRptTypCd }">selected="selected"</c:if>
	                                 >${opt.value}</option>
	                                </c:forEach>
	                                </select>
                                </div>
                            </div> --%>
                              <div class="fieldBox col_50">
                                <div class="label">调查人员签字：</div>
                                <div class="field">
                                <input name="investor" id="investor"  type="text"  class="ui-textbox" value="${prjCstInvestRpt.investor }" >
                                </div>
                            </div>
                            <div class="fieldBox col_50">
                                <div class="label">日期</div>
                                <div class="field"> 
                              		<input name="rptDt" id="rptDt" type="text"  class="ui-datepicker"  value="${prjCstInvestRpt.rptDt }" >
                                </div>
                            </div>
                              <div class="fieldBox col_50"  style="display: none">
                                <div class="field"> 
                              		<input name="rptId" id="rptId" type="text"  value="${prjCstInvestRpt.id }" >
                                </div>
                            </div>
                            </div>
                    </form>
                     <div class="btnsBox">
				                <span id="prj_cst_invest_rpt_add_btn_id" class="sq-button sq-button-round" onclick="save();"><!-- <i class="sqBtnIco_10"></i> -->保存</span>
           				 </div>   
           				 </div>
    			</div>
   </div>
</div>
</body>
</html>